package hn.sigit.logic.workflow.transaction;

import hn.sigit.logic.workflow.WorkflowHelper;
import hn.sigit.model.hnd.administrative.HND_Transaction;
import hn.sigit.model.hnd.administrative.HND_TransactionSubType;
import hn.sigit.model.hnd.administrative.HND_TransactionType;
import hn.sigit.model.hnd.cadastre.HND_SpatialZone;
import hn.sigit.model.ladm.administrative.LA_AdministrativeSource;
import hn.sigit.model.ladm.external.ExtParty;

import java.io.Serializable;
import java.util.List;
import java.util.Set;

import javax.ejb.Local;
import javax.ejb.Remove;
import javax.faces.model.SelectItem;

import org.jboss.seam.annotations.Begin;
import org.jboss.seam.annotations.Destroy;
import org.jboss.seam.annotations.End;
import org.jboss.seam.annotations.Transactional;
import org.jboss.seam.annotations.bpm.BeginTask;
import org.jboss.seam.annotations.bpm.CreateProcess;
import org.jboss.seam.annotations.bpm.EndTask;
import org.jbpm.taskmgmt.exe.TaskInstance;

@Local
public interface TransactionHelper extends WorkflowHelper, Serializable {
	String NAME = "transactionHelper";
	

	public static final String TRANSACTION_PROCESS = "transactionWorkflow";

	HND_Transaction getTransaction();

	void setTransaction(HND_Transaction transaction);

	public ExtParty getParty();

	public void setParty(ExtParty party);

	Long getTransactionId();

	void setTransactionId(Long transactionId);

	Long getPartyId();

	String getPartyFormalIdentity();

	String getPartyName();

	Set<HND_SpatialZone> getRequestedZoneSet();

	void setRequestedZoneSet(Set<HND_SpatialZone> requestedZoneSet);

	List<HND_SpatialZone> getRequestedZoneList();

	void setRequestedZoneList(List<HND_SpatialZone> requestedZoneList);

	List<LA_AdministrativeSource> getFileSources();

	void acceptSelectedFile();
	
	String hasAttachedFiles();

	@End
	@CreateProcess(definition = TRANSACTION_PROCESS, processKey = "#{transactionHelper.transactionId}")
	@Transactional
	String beginProcess();

	List<TaskInstance> getTaskInstanceList();

	List<TaskInstance> getPooledTaskInstanceList();

	@BeginTask
	@Begin(join = true)
	String startTask();

	@EndTask
	String endTask();

	@EndTask
	String endPresentation();

	@EndTask(transition="analysis_ok")
	String endAnalysisOK();
	
	@EndTask(transition="analysis_not_ok")
	String endAnalysisDenied();
	
	@EndTask(transition = "dataentry_ok")
	String endDataEntry();

	@EndTask(transition = "dataentry_back2analysis")
	String dataEntryBackToAnalysis();

	@EndTask(transition = "approval_ok")
	String endApproval();

	@EndTask(transition="approval_denied")
	String endApprovalDenied();

	String endProcess(boolean approved, String responseData);
	
	@EndTask(transition = "approval_back2analysis")
	String approvalBackToAnalysis();

	@EndTask(transition = "approval_back2dataentry")
	String approvalBackToDataEntry();

	HND_TransactionType getRequestType();

	void setRequestType(HND_TransactionType requestType);

	List<SelectItem> getRequestTypes();

	HND_TransactionSubType getRequestSubType();

	void setRequestSubType(HND_TransactionSubType requestSubType);

	List<SelectItem> getRequestSubTypes();

	String selectZonesFromMap();

	String excludeSelectedZone(HND_SpatialZone zone);

	@Destroy
	@Remove
	void destroy();

}
